﻿<%@ Page Title="Rule Defination" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="RuleDefinition.aspx.cs" Inherits="TestJQGrid.RuleDefinition" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <link rel="stylesheet" type="text/css" media="all" href="../jsdatepick-calendar/jsDatePick_ltr.min.css" />
    <script type="text/javascript" src="../jsdatepick-calendar/jsDatePick.min.1.3.js"></script>
    <script type="text/javascript">
        function getDate(cid)
        {
            new JsDatePick({
                    useMode: 2,
                    target: cid,
                    dateFormat: "%d-%M-%Y",
                });
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Label ID="lblMenuName" runat="server" Text="Label"></asp:Label>
    <table border="3" style="width: 100%;">
        <tr>
            <td rowspan="3" style="width: 20%;" align="left" valign="top" style="height: 100px;">
                <asp:ListBox ID="LBRule" runat="server" Width="100%" OnSelectedIndexChanged="LBRule_SelectedIndexChanged"
                    Rows="25" DataSourceID="SqlDataSource2" DataTextField="RuleName" DataValueField="RuleID"
                    AutoPostBack="True" Height="459px" OnDataBound="LBRule_DataBound"></asp:ListBox>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:AgentBillingConnectionString %>"
                    SelectCommand="SELECT [RuleID], [RuleName] FROM [RuleDetails] WHERE ([ProductName] = @ProductName)">
                    <SelectParameters>
                        <asp:SessionParameter DefaultValue="'default'" Name="ProductName" Type="String" SessionField="ProductName" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
            <td align="left" valign="top" style="height: 100px;">
                <asp:Panel runat="server" ID="PanelUpper">
                    &nbsp;<br />
                    &nbsp;<asp:Label ID="LabelName" runat="server" Text="Rule Name" Width="100px"></asp:Label>
                    <asp:TextBox ID="TBRuleName" runat="server" Width="260px"></asp:TextBox>
                    <br />
                    <br />
                    <asp:Label ID="LabelFrom" runat="server" Text="From Date" Width="100px"></asp:Label>
                    <asp:TextBox ID="TBFrom" runat="server" Width="120px" onClick="return getDate('MainContent_TBFrom');"></asp:TextBox>
                    <asp:Label ID="LabelDateTo" runat="server" Text="TO" Width="20px"></asp:Label>
                    <asp:TextBox ID="TBToDate" runat="server" Width="120px" onClick="return getDate('MainContent_TBToDate');"></asp:TextBox>
                    <br />
                    <br />
                    &nbsp;<asp:Label ID="LabelType" runat="server" Text="   Rule Type" Width="100px"></asp:Label>
                    <asp:DropDownList ID="DDLType" runat="server">
                        <asp:ListItem Selected="True">Basic</asp:ListItem>
                        <asp:ListItem>Additional</asp:ListItem>
                    </asp:DropDownList>
                    &nbsp;&nbsp; &nbsp;<asp:Label ID="LabelStatus" runat="server" Text="Rule Status"
                        Width="70px"></asp:Label>
                    &nbsp;&nbsp;&nbsp;
                    <asp:DropDownList ID="DDLStatus" runat="server" DataSourceID="SqlDataSource1" DataTextField="Value"
                        DataValueField="Value">
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AgentBillingConnectionString %>"
                        SelectCommand="SELECT Value FROM ValidValues WHERE (TableName = @TableName) AND (ColumnName = @ColumnName)">
                        <SelectParameters>
                            <asp:Parameter DefaultValue="Global" Name="TableName" Type="String" />
                            <asp:Parameter DefaultValue="EntryStatus" Name="ColumnName" Type="String" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                    &nbsp;
                    <asp:CheckBox ID="CBRepeats" runat="server" AutoPostBack="True" OnCheckedChanged="CBRepeats_CheckedChanged"
                        Text=" Repeat Every" Width="100px" />
                    &nbsp;<asp:DropDownList ID="DDLFrequency" runat="server" OnLoad="DDLFrequency_Load">
                    </asp:DropDownList>
                    &nbsp;&nbsp;&nbsp;
                    <asp:DropDownList ID="DDLFreqType" runat="server" OnSelectedIndexChanged="DDLFreqType_SelectedIndexChanged">
                        <asp:ListItem Selected="True">Days</asp:ListItem>
                        <asp:ListItem>Weeks</asp:ListItem>
                        <asp:ListItem>Month</asp:ListItem>
                        <asp:ListItem>Year</asp:ListItem>
                    </asp:DropDownList>
                </asp:Panel>
            </td>
        </tr>
        <tr>
            <td>
                <asp:Panel runat="server" ID="PanelMiddle" Enabled="False">
                    <table style="width: 100%; height: 100%;">
                        <tr>
                            <td style="width: 40%;">
                                <asp:Label ID="Label1" runat="server" Text="All SubRules"></asp:Label>
                                <br />
                                <asp:ListBox ID="LBAllRules" runat="server" Rows="15" Width="100%" DataSourceID="SqlDataSource3"
                                    DataTextField="FormulaName" DataValueField="ID" Enabled="False"></asp:ListBox>
                                <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:AgentBillingConnectionString %>"
                                    SelectCommand="SELECT [ID], [FormulaName] FROM [FormulaTable] WHERE (([FormulaType] = @FormulaType) )">
                                    <SelectParameters>
                                        <asp:Parameter DefaultValue="Subrule" Name="FormulaType" Type="String" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                            </td>
                            <td style="width: 10%;" align="center" valign="middle">
                                <asp:ImageButton ID="IBRight" runat="server" BorderStyle="Solid" Height="20px" ImageUrl="~/Image/arrow-right.jpg"
                                    Width="20px" OnClick="IBRight_Click" />
                                <br />
                                <br />
                                <asp:ImageButton ID="IBLeft" runat="server" BorderStyle="Solid" Height="20px" ImageUrl="~/Image/arrow-left.jpg"
                                    Width="20px" OnClick="IBLeft_Click" />
                            </td>
                            <td style="width: 40%;">
                                <asp:Label ID="Label2" runat="server" Text="Selected SubRules"></asp:Label>
                                <br />
                                <asp:ListBox ID="LBSelected" runat="server" Width="100%" Rows="15" DataSourceID="SqlDataSource5"
                                    DataTextField="FormulaName" DataValueField="SubRuleID"></asp:ListBox>
                                <asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:AgentBillingConnectionString %>"
                                    SelectCommand="select RuleRelations.SubRuleID, FormulaTable.FormulaName from RuleRelations, FormulaTable 
where RuleRelations.SubRuleID = FormulaTable.ID AND RuleRelations.RuleID = @RuleId ORDER BY RuleRelations.Priority">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="LBRule" Name="RuleId" PropertyName="SelectedValue" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                            </td>
                            <td style="width: 40%;" align="center" valign="middle">
                                <asp:ImageButton ID="IBUp" runat="server" BorderStyle="Solid" Height="20px" ImageUrl="~/Image/arrow-up.jpg"
                                    Width="20px" OnClick="IBUp_Click" />
                                <br />
                                <br />
                                <asp:ImageButton ID="IBDown" runat="server" BorderStyle="Solid" Height="20px" ImageUrl="~/Image/arrow-down.jpg"
                                    Width="20px" OnClick="IBDown_Click" />
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </td>
        </tr>
        <tr>
            <td align="center" valign="middle">
                <asp:Button ID="BApply" runat="server" Text="Apply" Width="100px" OnClick="BApply_Click" />
                &nbsp;<asp:Button ID="BCancel" runat="server" Text="Cancel" Width="100px" OnClick="BCancel_Click" />
                &nbsp;<asp:Button ID="BEdit" runat="server" Text="Edit" Width="100px" OnClick="BEdit_Click" />
                &nbsp;<asp:Button ID="BCreate" runat="server" Text="Create New" Width="100px" OnClick="BCreate_Click" />
            </td>
        </tr>
    </table>
</asp:Content>
